package com.ctg.payroll2.action.cusadmin;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.ctg.payroll2.service.cusadmin.PbCompanyService;
import com.ctg.payroll2.util.Constants;
import com.ctg.platform.util.Page;
import com.ctg.platform.util.Parse;
import com.googlecode.jsonplugin.annotations.JSON;
import com.opensymphony.xwork2.ActionSupport;

public class CompanyAction extends ActionSupport {

	private PbCompanyService companyService;
	private static final long serialVersionUID = 4008074459618201631L;

	private Page result;

	public Page getResult() {
		return result;
	}

	public void setResult(Page result) {
		this.result = result;
	}

	public String getLinkmanByCompanyCode() {
		try {
			HttpServletRequest request = ServletActionContext.getRequest();
			String company_code = Parse.toString(request
					.getParameter("company_code"), false);
			String company_name = request.getParameter("company_name");

//			System.out.println(company_name);
			if (company_code != null) {
				Map<String, Object> paraMap = new HashMap<String, Object>();
				paraMap.put("company_code", company_code);
				Integer start = Parse.toInteger(request.getParameter("start"),
						0);
				Integer limit = Parse.toInteger(request.getParameter("limit"),
						Constants.DEFAULT_PAGE_SIZE);
				result = companyService.getLinkMan(paraMap, start, limit);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return SUCCESS;
	}
	@JSON(serialize = false)
	public PbCompanyService getCompanyService() {
		return companyService;
	}

	public void setCompanyService(PbCompanyService companyService) {
		this.companyService = companyService;
	}
}
